﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebDS;
using WebUS;
using WebDS.CDBNames;
using IP.Core.IPCommon;
using System.Data;
using IP.Core.IPData.DBNames;
using IP.Core.IPData;
using IP.Core.IPUserService;

public partial class ChucNang_Ban_giao_thiet_bi : System.Web.UI.Page
{
    #region bienToanCuc
    US_GD_BAO_TRI_THONG_TIN_CHUNG m_us_gd_bao_tri_thong_tin_chung = new US_GD_BAO_TRI_THONG_TIN_CHUNG();
    DS_GD_BAO_TRI_THONG_TIN_CHUNG m_ds_gd_bao_tri_thong_tin_chung = new DS_GD_BAO_TRI_THONG_TIN_CHUNG();
    int m_id_bao_tri_thiet_bi;
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        m_id_bao_tri_thiet_bi = Convert.ToInt32(Request.Cookies["Id"].Value);
        if (!IsPostBack)
        {
            loadDataGridViewThongTinChung();
        }
    }

    protected void loadDataGridViewThongTinChung()
    {
        US_GD_BAO_TRI_THONG_TIN_CHUNG v_us_gd_bao_tri_thong_tin_chung = new US_GD_BAO_TRI_THONG_TIN_CHUNG();
        DS_GD_BAO_TRI_THONG_TIN_CHUNG v_ds_gd_bao_tri_thong_tin_chung = new DS_GD_BAO_TRI_THONG_TIN_CHUNG();
        v_us_gd_bao_tri_thong_tin_chung.filldataset_gd_bao_tri_thong_tin_chung_id_dot_bao_tri(m_id_bao_tri_thiet_bi,v_ds_gd_bao_tri_thong_tin_chung);
        m_grv_dm_su_co.DataSource = v_ds_gd_bao_tri_thong_tin_chung;
        m_grv_dm_su_co.DataBind();
    }

    protected void xoa_form()
    {
        m_txt_nhan_dinh_ban_dau.Text = "";
        m_txt_thoi_gian_bao_loi.Text = "";
        m_txt_thoi_gian_di.Text = "";
        m_txt_tinh_trang_su_co.Text = "";
    }

    protected void form_2_us_object()
    {
        m_us_gd_bao_tri_thong_tin_chung.strTINH_TRANG_SU_CO = m_txt_tinh_trang_su_co.Text;
        m_us_gd_bao_tri_thong_tin_chung.strNHAN_DINH_BAN_DAU = m_txt_nhan_dinh_ban_dau.Text;
        m_us_gd_bao_tri_thong_tin_chung.datTHOI_GIAN_BAO_LOI = m_txt_thoi_gian_bao_loi.SelectedDate;
        m_us_gd_bao_tri_thong_tin_chung.datTHOI_GIAN_DI = m_txt_thoi_gian_di.SelectedDate;
        m_us_gd_bao_tri_thong_tin_chung.dcID_DOT_BAO_TRI = m_id_bao_tri_thiet_bi;
    }

    protected void m_btn_them_su_co_moi_Click(object sender, EventArgs e)
    {        
        form_2_us_object();
        m_us_gd_bao_tri_thong_tin_chung.Insert();
        loadDataGridViewThongTinChung();
        xoa_form();
    }
    protected void m_btn_tiep_tuc_Click(object sender, EventArgs e)
    {
        Response.Cookies["Id"].Value = m_id_bao_tri_thiet_bi.ToString();
        Response.Redirect("~/ChucNang/BaoTriThietBi/Noi_dung_cong_tac.aspx");
    }
}